/*
 * @Descripttion:
 * @version:
 * @Author:
 * @Date: 2021-09-07 09:27:25
 * @LastEditors: xiaochengang
 * @LastEditTime: 2021-09-07 10:11:08
 */
export function throttle (fn, ms) {
    let last = 0
    return function (...args) {
        let now = new Date()
        // console.log(last - now)
        if (now - last >= ms) {
            fn.call(this, ...args)
            last = now
        }
    }
}
export function debounce (fn, ms) {
    let timer = null
    return function () {
        if (timer) clearTimeout(timer)
        timer = setTimeout(() => {
            fn.call(this, ...arguments)
            timer = null
        }, ms)
    }
}